stack = []
print('Введите скобочную последовательность')
s = input()
if (s[0] ==')') or (s[0] ==']') or (s[0] =='}') or (s[0] =='>'):
    print('False')
elif (s[-1] =='(') or (s[-1] =='[') or (s[-1] =='{') or (s[-1] =='<'):
    print('False')
else:
    for i in s:
        if i in '([{<':
            stack.append(i)
        else:
            if i == ')' and stack[-1] == '(':
                stack.pop()
            elif i == ']' and stack[-1] == '[':
                stack.pop()
            elif i == '}' and stack[-1] == '{':
                stack.pop()
            elif i == '>' and stack[-1] == '<':
                stack.pop()
            else:
                break
    if len(stack) == 0:
        print('True')
    else:
        print('False')
